﻿// /samples/tutorial/buttons/buttons.cs - Gtk# Tutorial example
//
// Author: Johannes Roith <johannes@jroith.de>
//
// (c) 2002 Johannes Roith

namespace GtkSharpTutorial
{

    using Gtk;
    using System;
    using System.Drawing;


    public class NormalButtons
    {
        /* Our usual callback function */
        void callback(object obj, EventArgs args)
        {
            Console.WriteLine("Hello again - cool button was pressed");
        }

        /* Create a new hbox with an image and a label packed into it
         * and return the box. */

        Widget GetBox(string picture_filename, string label_text)
        {
            /* Create box for image and label */
            VBox box = new VBox(false, 0);
            box.BorderWidth = 2;

            /* Now on to the image stuff */
            Gtk.Image image = new Gtk.Image(picture_filename);

            /* Create a label for the button */
            Label label = new Label(label_text);

            /* Pack the image and label into the box */
            box.PackStart(image, false, false, 3);
            box.PackStart(label, false, false, 3);

            image.Show();
            label.Show();

            return box;
        }

        public Widget GetButton(string picture_filename, string label_text)
        {
            /* Create a new button */
            Button button = new Button();

            /* Connect the "clicked" signal of the button to our callback */
            button.Clicked += callback;

            /* This calls our box creating function */
            Widget box = GetBox(picture_filename, label_text);

            /* Pack and show all our widgets */
            box.Show();

            button.Add(box);

            button.Show();

            return button;
        }
    }
}